import { createI18n } from 'vue-i18n';
import * as zhCn from './zh-CN';

const LanguageTypes = {
  zh: 'zh-CN',
  zhCn: 'zh-CN',
  en: 'en-US',
  enUS: 'en-US',
};

const messages = {
  [LanguageTypes.zhCn]: zhCn,
};

const i18n = createI18n({
  locale: LanguageTypes.zhCn,
  fallbackLocale: LanguageTypes.enUS,
  messages,
});

const setLanguage = (lang: string) => {
  i18n.global.locale = lang;
};

export { i18n, LanguageTypes, setLanguage };
